package com.wgh.api.client.order;

import com.wgh.api.client.fallback.OrderClientFallback;
import com.wgh.order.dto.OrderDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * 订单服务客户端接口
 */
@FeignClient(name = "shop-order", fallback = OrderClientFallback.class)
public interface OrderClient {

    /**
     * 创建订单
     */
    @PostMapping("/order/create")
    OrderDTO createOrder(@RequestBody Map<String, Object> orderParams);

    /**
     * 根据订单ID查询订单信息
     */
    @GetMapping("/order/{id}")
    OrderDTO findById(@PathVariable("id") Long id);

    /**
     * 根据用户ID查询订单列表
     */
    @GetMapping("/order/list")
    List<OrderDTO> findListByUserId(@RequestParam("userId") Long userId,
                                 @RequestParam("page") Integer page,
                                 @RequestParam("size") Integer size);

    /**
     * 更新订单状态
     */
    @PostMapping("/order/update-status")
    Boolean updateOrderStatus(@RequestParam("orderId") Long orderId,
                             @RequestParam("status") Integer status);

    /**
     * 取消订单
     */
    @PostMapping("/order/cancel")
    Boolean cancelOrder(@RequestParam("orderId") Long orderId);
}